



************************ 
************************ Table A3


use "data\data_desc_3_USimp.dta", clear

eststo clear

eststo R1: reghdfe L_v 1.y2000#1.MEX#1.HIGH_t , absorb(g_ct g_pt g_pc) cluster(hs6 year MEX)



use "data\data_desc_4_USexp.dta", clear

eststo R2: reghdfe L_v 1.y2000#1.MEX#1.HIGH , absorb(g_ct g_pt g_pc) cluster(hs6 year MEX)

esttab R1 R2 using "results\w3\tA3.tex", replace se obs star(* 0.10 ** 0.05 *** 0.01) label nocons nogaps b(%9.3f) se(%9.3f)  ///
mtitle("" "" "" "" "" "")  


************************ Table A5 panel A
************************ 

use "data\data1_regional.dta", clear


summ D_t_US D_t_US_alt1 D_t_US_alt2 D_t_MEX D_t_MEX_alt1 D_t_MEX_alt2, det 

foreach var in D_t_US D_t_US_alt1 D_t_US_alt2 D_t_MEX D_t_MEX_alt1 D_t_MEX_alt2 {
summ `var' [aw= timepwt48 ], det 
scalar mean_`var' = r(mean)
scalar sd_`var' = r(sd)
scalar p10_`var' = r(p10)
scalar p25_`var' = r(p25)
scalar p50_`var' = r(p50)
scalar p75_`var' = r(p75)
scalar p90_`var' = r(p90)
}
*

clear 
set obs 20

foreach x in mean sd p10 p25 p50 p75 p90 {
gen `x' = .
}
*
gen name = ""

local i = 1
foreach var in D_t_US D_t_US_alt1 D_t_US_alt2 D_t_MEX D_t_MEX_alt1 D_t_MEX_alt2 {

foreach x in mean sd p10 p25 p50 p75 p90 {
replace `x' = `x'_`var' if _n == `i'
}
replace name = "`var'" if _n == `i'
local i = `i' + 1
}
*

gen b1 = "&"
gen b2 = "&"
gen b3 = "&"
gen b4 = "&"
gen b5 = "&"
gen b6 = "&"
gen b7 = "&"
gen b8 = "\\"

order name b1 mean b2 sd b3 p10 b4 p25 b5 p50 b6 p75 b7 p90 b8

tostring mean sd p10 p25 p50 p75 p90 , replace force format(%7.2f)










************************ Table A5 panel B
************************ 

use "data\data1_regional.dta", clear

foreach HHC in 0 1 {
foreach var in  D_t_US D_t_MEX {
summ `var' [aw= timepwt48] if HHC == `HHC', det 
scalar mean_`var'_HC`HHC' = r(mean)
scalar sd_`var'_HC`HHC'  = r(sd)
scalar p10_`var'_HC`HHC'  = r(p10)
scalar p25_`var'_HC`HHC'  = r(p25)
scalar p50_`var'_HC`HHC'  = r(p50)
scalar p75_`var'_HC`HHC'  = r(p75)
scalar p90_`var'_HC`HHC'  = r(p90)
}
}
*

clear 
set obs 20

foreach x in mean sd p10 p25 p50 p75 p90 {
gen `x' = .
}
*
gen name = ""

local i = 1
foreach HHC in 0 1 {
foreach var in  D_t_US D_t_MEX {
foreach x in mean sd p10 p25 p50 p75 p90 {
replace `x' = `x'_`var'_HC`HHC' if _n == `i'
}
replace name = "`var'" + "`HHC'" if _n == `i'
local i = `i' + 1
}
}
*

gen b1 = "&"
gen b2 = "&"
gen b3 = "&"
gen b4 = "&"
gen b5 = "&"
gen b6 = "&"
gen b7 = "&"
gen b8 = "\\"

order name b1 mean b2 sd b3 p10 b4 p25 b5 p50 b6 p75 b7 p90 b8

tostring mean sd p10 p25 p50 p75 p90 , replace force format(%7.2f)









************** Table A9
************** 


use "data\data1_regional.dta", clear


summ xCHN xOTH [aw= timepwt48 ], det

foreach var in xCHN xOTH {
summ `var' [aw= timepwt48], det 
scalar mean_`var' = r(mean)
scalar sd_`var' = r(sd)
scalar p10_`var' = r(p10)
scalar p25_`var' = r(p25)
scalar p50_`var' = r(p50)
scalar p75_`var' = r(p75)
scalar p90_`var' = r(p90)
}
*

clear 
set obs 2

foreach x in mean sd p10 p25 p50 p75 p90 {
gen `x' = .
}
*
gen name = ""

local i = 1
foreach var in xCHN xOTH {
foreach x in mean sd p10 p25 p50 p75 p90 {
replace `x' = `x'_`var' if _n == `i'
}
replace name = "`var'" if _n == `i'
local i = `i' + 1
}
*

gen b1 = "&"
gen b2 = "&"
gen b3 = "&"
gen b4 = "&"
gen b5 = "&"
gen b6 = "&"
gen b7 = "&"
gen b8 = "\\"

order name b1 mean b2 sd b3 p10 b4 p25 b5 p50 b6 p75 b7 p90 b8

tostring mean sd p10 p25 p50 p75 p90 , replace force format(%7.2f)





************************ Table A10
************************ 


use "data\data1_regional.dta", clear

foreach var in l_sh_routine33 R33a_1950_90 {
summ `var' [aw= timepwt48], det 
scalar mean_`var' = r(mean)
scalar sd_`var' = r(sd)
scalar p10_`var' = r(p10)
scalar p25_`var' = r(p25)
scalar p50_`var' = r(p50)
scalar p75_`var' = r(p75)
scalar p90_`var' = r(p90)
}
*

clear 
set obs 2

foreach x in mean sd p10 p25 p50 p75 p90 {
gen `x' = .
}
*
gen name = ""

local i = 1
foreach var in l_sh_routine33 R33a_1950_90 {
foreach x in mean sd p10 p25 p50 p75 p90 {
replace `x' = `x'_`var' if _n == `i'
}
replace name = "`var'" if _n == `i'
local i = `i' + 1
}
*

gen b1 = "&"
gen b2 = "&"
gen b3 = "&"
gen b4 = "&"
gen b5 = "&"
gen b6 = "&"
gen b7 = "&"
gen b8 = "\\"

order name b1 mean b2 sd b3 p10 b4 p25 b5 p50 b6 p75 b7 p90 b8

tostring mean sd p10 p25 p50 p75 p90 , replace force format(%7.2f)












***************** Table A6 panel A
***************** 

use "data\data_desc_1.dta", clear


foreach y in 1993 1994 1997 2000 {
summ t_czone_`y' [aw=time], det
scalar mean_`y' = r(mean)
scalar sd_`y' = r(sd)
scalar p10_`y' = r(p10)
scalar p25_`y' = r(p25)
scalar p50_`y' = r(p50)
scalar p75_`y' = r(p75)
scalar p90_`y' = r(p90)
}

clear
set obs 4
foreach var in mean sd p10 p25 p50 p75 p90 {
gen `var' = .
}
*	   
gen year = .
local i = 1
foreach y in 1993 1994 1997 2000 {
foreach var in mean sd p10 p25 p50 p75 p90 {
replace `var' = `var'_`y' if _n == `i'
replace year = `y' if _n == `i'
}
local i = `i' + 1
}
*	   

forvalues x = 1/7 {
gen b`x' = "&"
}
gen bend = "\\"	
tostring mean sd p*, format(%7.2f) replace force  
order year b1 mean b2 sd b3 p10 b4 p25 b5 p50 b6 p75 b7 p90 bend	   
	   
	   
	   
	   
	   
	   
***************** Table A6 panel B
***************** 

use "data\data_desc_2.dta", clear

foreach y in 1993 1994 1997 2000 {
summ t_czone_`y' [aw=time], det
scalar mean_`y' = r(mean)
scalar sd_`y' = r(sd)
scalar p10_`y' = r(p10)
scalar p25_`y' = r(p25)
scalar p50_`y' = r(p50)
scalar p75_`y' = r(p75)
scalar p90_`y' = r(p90)
}

clear
set obs 4
foreach var in mean sd p10 p25 p50 p75 p90 {
gen `var' = .
}
*	   
gen year = .
local i = 1
foreach y in 1993 1994 1997 2000 {
foreach var in mean sd p10 p25 p50 p75 p90 {
replace `var' = `var'_`y' if _n == `i'
replace year = `y' if _n == `i'
}
local i = `i' + 1
}
*	   

forvalues x = 1/7 {
gen b`x' = "&"
}
gen bend = "\\"	
tostring mean sd p*, format(%7.2f) replace force  
order year b1 mean b2 sd b3 p10 b4 p25 b5 p50 b6 p75 b7 p90 bend	   
	   



	   
	   
	   

********************
******************** Table A7; panel A

use "data\data1_regional.dta", clear

gsort -l_pop
keep if _n <= 100

keep czone D_t_US statecode czname

gsort D_t_US
gen top = 1 if _n <= 10
gen bottom = 1 if _n >= _N-10
keep if top == 1 | bottom == 1

gsort D_t_US

gen id = _n
replace id = id + 80 - 1 if id >= 11
keep D_t_US czname id statecode
order id czname D_t_US 

tostring D_t_US, replace force format(%7.3f)

save "work\w5desc_tA7_aux1.dta", replace


use "work\w5desc_tA7_aux1.dta", clear
keep if id >= 91
gen id2 = _n
sort id2
save "work\w5desc_tA7_aux2.dta", replace


use "work\w5desc_tA7_aux1.dta", clear
keep if id <= 10
gen id2 = id
rename id id_p1
rename czname czname_p1
rename statecode statecode_p1 
rename D_t_US D_t_US_p1
sort id2
merge id2 using "work\w5desc_tA7_aux2.dta"
tab _merge
keep if _merge == 3
drop _merge

gen b1 = "&"
gen b2 = "&" 
gen b3 = "&" 
gen b4 = "&" 
gen b5 = "&" 
gen b6 = "&" 
gen b7 = "&" 
gen b_end = "\\"

keep id_p1 b1 czname_p1 b2 statecode_p1 b3 D_t_US_p1 b4 id b5 czname b6 statecode b7 D_t_US b_end
order id_p1 b1 czname_p1 b2 statecode_p1 b3 D_t_US_p1 b4 id b5 czname b6 statecode b7 D_t_US b_end

********************
********************
	   
	   
	   
	   

********************
******************** Table A7; panel B

use "data\data1_regional.dta", clear

gsort -l_pop
keep if _n <= 100


keep czone D_t_MEX statecode czname

gsort D_t_MEX
gen top = 1 if _n <= 10
gen bottom = 1 if _n >= _N-10
keep if top == 1 | bottom == 1

gsort D_t_MEX

gen id = _n
replace id = id + 80 - 1 if id >= 11
keep D_t_MEX czname id statecode
order id czname D_t_MEX 

tostring D_t_MEX, replace force format(%7.3f)

save "work\w5desc_tA7_aux3.dta", replace


use "work\w5desc_tA7_aux3.dta", clear
keep if id >= 91
gen id2 = _n
sort id2
save "work\w5desc_tA7_aux4.dta", replace


use "work\w5desc_tA7_aux3.dta", clear
keep if id <= 10
gen id2 = id
rename id id_p1
rename czname czname_p1
rename statecode statecode_p1 
rename D_t_MEX D_t_MEX_p1
sort id2
merge id2 using "work\w5desc_tA7_aux4.dta"
tab _merge
keep if _merge == 3
drop _merge

gen b1 = "&"
gen b2 = "&" 
gen b3 = "&" 
gen b4 = "&" 
gen b5 = "&" 
gen b6 = "&" 
gen b7 = "&" 
gen b_end = "\\"

keep id_p1 b1 czname_p1 b2 statecode_p1 b3 D_t_MEX_p1 b4 id b5 czname b6 statecode b7 D_t_MEX b_end
order id_p1 b1 czname_p1 b2 statecode_p1 b3 D_t_MEX_p1 b4 id b5 czname b6 statecode b7 D_t_MEX b_end

********************
********************








******************* Table A8 panel A
******************* 

use "data\data_desc_5_US_ind2.dta", clear

forvalues x = 1/5 {
gen b`x' = "&"
}
gen bend = "\\"

sort D_t
gen rank = _n

replace num_all = num_all / 1000
tostring num_all, replace force format(%7.0f)
tostring sh_nw sh_f, replace force format(%7.2f)
tostring D_t, replace force format(%7.2f)
replace name = proper(name)

order rank b1 name b2 num_all b3 sh_f b4 sh_nw b5 D_t bend
keep rank b1 name b2 num_all b3 sh_f b4 sh_nw b5 D_t bend




******************* Table A8 panel B
******************* 

use "data\data_desc_6_MEX_ind2.dta", clear


forvalues x = 1/5 {
gen b`x' = "&"
}
gen bend = "\\"

sort D_t
gen rank = _n

replace num_all = num_all / 1000
tostring num_all, replace force format(%7.0f)
tostring sh_nw sh_f, replace force format(%7.2f)
tostring D_t, replace force format(%7.2f)
replace name = proper(name)

order rank b1 name b2 num_all b3 sh_f b4 sh_nw b5 D_t bend
keep rank b1 name b2 num_all b3 sh_f b4 sh_nw b5 D_t bend






******************* Table A33
******************* 

use "data\data1_regional.dta", clear

summ D_t_US_F [aw=time], det
foreach x in mean sd p10 p25 p50 p75 p90 {
scalar rF_`x' = r(`x')
}

summ D_t_US_M [aw=time], det
foreach x in mean sd p10 p25 p50 p75 p90 {
scalar rM_`x' = r(`x')
}

clear
set obs 2
foreach x in mean sd p10 p25 p50 p75 p90 {
gen c_`x' = .
}

foreach x in mean sd p10 p25 p50 p75 p90 {
replace c_`x' = rF_`x' if _n == 1
replace c_`x' = rM_`x' if _n == 2
}

gen name = "D_t_US_F" if _n == 1
replace name = "D_t_US_M" if _n == 2

forvalues x = 1/7 {
gen b`x' = "&"
}
gen bend = "\\"

order name b1 c_mean b2 c_sd b3 c_p10 b4 c_p25 b5 c_p50 b6 c_p75 b7 c_p90 bend

tostring c_mean, replace force format(%7.3f)
tostring c_sd c_p10 c_p25 c_p50 c_p75 c_p90, replace force format(%7.2f)







******************* Table A4 (first part)
******************* 


foreach var in empl_mfg empl_nmfg empl unempl nilf {

use "data\data_desc_7_summ_stats.dta", clear


summ l_sh_`var'  [aw=time] if yr == 1990
scalar m1_all_t0 = r(mean)
scalar s1_all_t0 = r(sd)

summ l_sh_`var'  [aw=time] if yr == 2000
scalar m1_all_t1 = r(mean)
scalar s1_all_t1 = r(sd)

summ d_sh_`var'  [aw=time] if yr == 1990
scalar m1_all_t0t1 = r(mean)
scalar s1_all_t0t1 = r(sd)

foreach x in edu_nc edu_c f m nw w {
summ l_sh_`var'_`x'  [aw=time] if yr == 1990
scalar m1_`x'_t0 = r(mean)
scalar s1_`x'_t0 = r(sd)

summ l_sh_`var'_`x'  [aw=time] if yr == 2000
scalar m1_`x'_t1 = r(mean)
scalar s1_`x'_t1 = r(sd)

summ d_sh_`var'_`x'  [aw=time] if yr == 1990
scalar m1_`x'_t0t1 = r(mean)
scalar s1_`x'_t0t1 = r(sd)
}
*



clear
set obs 15
gen v1_1990 = .
gen v1_2000 = .
gen v1_change = .

replace v1_1990 = m1_all_t0 if _n == 1
replace v1_1990 = s1_all_t0 if _n == 2

replace v1_2000 = m1_all_t1 if _n == 1
replace v1_2000 = s1_all_t1 if _n == 2

replace v1_change = m1_all_t0t1 if _n == 1
replace v1_change = s1_all_t0t1 if _n == 2

local i = 3
foreach x in edu_nc edu_c f m nw w {

replace v1_1990 = m1_`x'_t0 if _n == `i'
replace v1_1990 = s1_`x'_t0 if _n == `i' + 1

replace v1_2000 = m1_`x'_t1 if _n == `i'
replace v1_2000 = s1_`x'_t1 if _n == `i' + 1

replace v1_change = m1_`x'_t0t1 if _n == `i'
replace v1_change = s1_`x'_t0t1 if _n == `i' + 1

local i = `i' + 2
}
*

tostring v1_1990 v1_2000 v1_change, replace force format(%7.1f)

replace v1_1990 = "(" + v1_1990 + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12 | _n == 14
replace v1_2000 = "(" + v1_2000 + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12  | _n == 14 
replace v1_change = "(" + v1_change + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10  | _n == 12 | _n == 14

gen b1 = "&"
gen b2 = "&"
gen b3 = "\\"

order v1_1990 b1 v1_2000 b2 v1_change b3

save "work\w5desc_tA4_`var'.dta", replace

}
*







******************* Table A4 (second part)
******************* 


use "data\data_desc_7_summ_stats.dta", clear

local var empl

foreach x in constr trans_util trade other_serv gov {
summ l_sh_`var'_`x'  [aw=time] if yr == 1990
scalar m1_`x'_t0 = r(mean)
scalar s1_`x'_t0 = r(sd)

summ l_sh_`var'_`x'  [aw=time] if yr == 2000
scalar m1_`x'_t1 = r(mean)
scalar s1_`x'_t1 = r(sd)

summ d_sh_`var'_`x'  [aw=time] if yr == 1990
scalar m1_`x'_t0t1 = r(mean)
scalar s1_`x'_t0t1 = r(sd)
}
*



clear
set obs 10
gen v1_1990 = .
gen v1_2000 = .
gen v1_change = .


local i = 1
foreach x in constr trans_util trade other_serv gov {

replace v1_1990 = m1_`x'_t0 if _n == `i'
replace v1_1990 = s1_`x'_t0 if _n == `i' + 1

replace v1_2000 = m1_`x'_t1 if _n == `i'
replace v1_2000 = s1_`x'_t1 if _n == `i' + 1

replace v1_change = m1_`x'_t0t1 if _n == `i'
replace v1_change = s1_`x'_t0t1 if _n == `i' + 1

local i = `i' + 2
}
*

tostring v1_1990 v1_2000 v1_change, replace force format(%7.1f)

replace v1_1990 = "(" + v1_1990 + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12 | _n == 14
replace v1_2000 = "(" + v1_2000 + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12  | _n == 14 
replace v1_change = "(" + v1_change + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10  | _n == 12 | _n == 14

gen b1 = "&"
gen b2 = "&"
gen b3 = "\\"

order v1_1990 b1 v1_2000 b2 v1_change b3

save "work\w5desc_tA4_part2.dta", replace



******************* Table A4 (third part)
******************* 


foreach var in abstract clerical production manual {

use "data\data_desc_7_summ_stats.dta", clear


summ l_sh_empl_`var'  [aw=time] if yr == 1990
scalar m1_all_t0 = r(mean)
scalar s1_all_t0 = r(sd)
summ l_sh_empl_`var'  [aw=time] if yr == 2000
scalar m1_all_t1 = r(mean)
scalar s1_all_t1 = r(sd)

summ d_sh_empl_`var'  [aw=time] if yr == 1990
scalar m1_all_t0t1 = r(mean)
scalar s1_all_t0t1 = r(sd)

foreach x in nc c {
summ l_sh_empl_`x'_`var'  [aw=time] if yr == 1990
scalar m1_`x'_t0 = r(mean)
scalar s1_`x'_t0 = r(sd)

summ l_sh_empl_`x'_`var'  [aw=time] if yr == 2000
scalar m1_`x'_t1 = r(mean)
scalar s1_`x'_t1 = r(sd)

summ d_sh_empl_`x'_`var'  [aw=time] if yr == 1990
scalar m1_`x'_t0t1 = r(mean)
scalar s1_`x'_t0t1 = r(sd)
}
*



clear
set obs 6
gen v1_1990 = .
gen v1_2000 = .
gen v1_change = .

replace v1_1990 = m1_all_t0 if _n == 1
replace v1_1990 = s1_all_t0 if _n == 2

replace v1_2000 = m1_all_t1 if _n == 1
replace v1_2000 = s1_all_t1 if _n == 2

replace v1_change = m1_all_t0t1 if _n == 1
replace v1_change = s1_all_t0t1 if _n == 2

local i = 3
foreach x in nc c {

replace v1_1990 = m1_`x'_t0 if _n == `i'
replace v1_1990 = s1_`x'_t0 if _n == `i' + 1

replace v1_2000 = m1_`x'_t1 if _n == `i'
replace v1_2000 = s1_`x'_t1 if _n == `i' + 1

replace v1_change = m1_`x'_t0t1 if _n == `i'
replace v1_change = s1_`x'_t0t1 if _n == `i' + 1

local i = `i' + 2
}
*

tostring v1_1990 v1_2000 v1_change, replace force format(%7.1f)

replace v1_1990 = "(" + v1_1990 + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12 | _n == 14
replace v1_2000 = "(" + v1_2000 + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10 | _n == 12  | _n == 14 
replace v1_change = "(" + v1_change + ")"  if _n == 2 | _n == 4 | _n == 6 | _n == 8 | _n == 10  | _n == 12 | _n == 14

gen b1 = "&"
gen b2 = "&"
gen b3 = "\\"

order v1_1990 b1 v1_2000 b2 v1_change b3

save "work\w5desc_tA4_`var'.dta", replace

}
*



